//
//  headPromptView.m
//  BeautyPicture
//
//  Created by 沈振邦 on 15/9/9.
//  Copyright (c) 2015年 szb. All rights reserved.
//

#import "headPromptView.h"

@implementation headPromptView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat imageW = 30.0f;
        _promptImage = [[UIImageView alloc] init];
        _promptImage.size = CGSizeMake(imageW, imageW);
        _promptImage.center = CGPointMake(frame.size.width / 2.0, imageW / 2.0);
        [self addSubview:_promptImage];
        
        CGFloat textY = CGRectGetMaxY(_promptImage.frame)+15.0f;
        _promptText = [[UILabel alloc] initWithFrame:CGRectMake(0, textY, BPScreenW, imageW)];
        _promptText.textAlignment = NSTextAlignmentCenter;
        _promptText.font = [UIFont systemFontOfSize:20.0f];
        [self addSubview:_promptText];
        
        CGFloat detailY = CGRectGetMaxY(_promptText.frame);
        _detailText = [[UILabel alloc] initWithFrame:CGRectMake(0, detailY, BPScreenW, 30.0)];
        _detailText.textAlignment = NSTextAlignmentCenter;
        _detailText.font = [UIFont systemFontOfSize:15.0f];
        [self addSubview:_detailText];
    }
    return self;
}

- (void)setUpPromptView:(NSString *)imageName and:(NSString *)labelText withDetailInfo:(NSString *)detailText
{
    _promptImage.image = [UIImage imageNamed:imageName];
    
    _promptText.text = labelText;
    
    if (detailText != nil) {
        NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"您的订单号:%@",detailText]];
        NSRange contentRange = {6,[attStr length] - 6};
        [attStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0f] range:contentRange];
        [attStr addAttribute:NSForegroundColorAttributeName value:BPGlobaThemeColor range:contentRange];
        //创建NSMutableParagraphStyle实例
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
        [style setAlignment:NSTextAlignmentCenter];
        //设置行距
        [attStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, [attStr length])];
        //Label获取attStr式样
        _detailText.attributedText = attStr;
    }else{
        _detailText = nil;
    }
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
